package com.isoftstone.project.system.controller;

import com.isoftstone.common.BusinessException;
import com.isoftstone.common.constant.Constants;
import com.isoftstone.framework.controller.BaseController;
import com.isoftstone.framework.domain.Page;
import com.isoftstone.framework.domain.PageData;
import com.isoftstone.framework.domain.Tidings;
import com.isoftstone.project.system.domain.SysLogOperate;
import com.isoftstone.project.system.service.ISysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class SysLogController extends BaseController {

    @Autowired
    ISysLogService logService;

    /**
     * 操作日志
     * @return
     */
    @RequestMapping("/system/log/logoperatelist")
    public ModelAndView rolelist() {
        return new ModelAndView("system/log/operatelog");
    }

    @RequestMapping("/system/log/getlogoperatelistPage")
    @ResponseBody
    public Object getlogoperatelistPage(Page page) {
        Tidings<List<SysLogOperate>> tidings = new Tidings<List<SysLogOperate>>();
        PageData pd = this.getPageData();
        page.setPd(pd);
        try {
            List<SysLogOperate> operates = logService.getlogoperatelistPage(page);
            tidings.setT(operates);
            tidings.setTotalResult(page.getTotalResult());
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException(Constants.ERRORMSG);
        }
        return tidings;
    }

}

